package org.hadoop.hive;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class HiveJdbc {
    public static void main(String[] args) throws Exception {
        Class.forName("org.apache.hive.jdbc.HiveDriver");
        String url = "jdbc:hive2://server201:10000/one";
        Connection con = DriverManager.getConnection(url,"hadoop","");
        Statement st  = con.createStatement();
        ResultSet rs = st.executeQuery("select * from stud");
        while(rs.next()) {
            String id = rs.getString("id");
            String name = rs.getString("name");
            System.out.println("id:"+id+",name:"+name);
        }
        rs.close();
        st.close();
        con.close();
    }
}
